on awake from nib theObject
	set documentToolbar to make new toolbar at end with properties {name:"document toolbar", identifier:"document toolbar identifier", allows customization:true, auto sizes cells:true, display mode:default display mode, size mode:default size mode}
	
	-- Setup the allowed and default identifiers.  extra --> "print item identifier", "customize toolbar item identifier",
	set allowed identifiers of documentToolbar to {"criar item identifier", "ver item identifier", "criarDB item identifier", "prefs item identifier", "flexible space item identifier", "space item identifier", "separator item identifier"}
	set default identifiers of documentToolbar to {"criar item identifier", "ver item identifier", "flexible space item identifier", "criar DB item identifier", "prefs item identifier"}
	
	--set selectable identifiers of documentToolbar to {}
	
	-- Create the toolbar items, adding them to the toolbar.
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"criar item identifier", name:"criar item", label:"Criar Registo", palette label:"Criar Registo", tool tip:"Criar um novo registo", image name:"add_icon.png"}
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"ver item identifier", name:"ver item", label:"Ver/Editar Registo", palette label:"Ver/Editar Registo", tool tip:"Ver/Editar Registo", image name:"search_icon.png"}
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"criarDB item identifier", name:"criarDB item", label:"Criar DB", palette label:"Criar DB", tool tip:"Criar DB", image name:"criarDB_icon.png"}
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"prefs item identifier", name:"prefs item", label:"Preferências", palette label:"Preferências", tool tip:"Preferências", image name:"prefs_icon.png"}
	
	-- Assign our toolbar to the window
	set toolbar of theObject to documentToolbar
end awake from nib

on clicked toolbar item theObject
	if identifier of theObject is "criar item identifier" then
		call method "makeKeyAndOrderFront:" of object window "Criar Obra"
		--display dialog "It's time to compile" attached to the front window
	else if identifier of theObject is "ver item identifier" then
		call method "makeKeyAndOrderFront:" of object window "PrePress Ver Obras"
		set contents of text field "procuraObras" of window "PrePress Ver Obras" to ""
	else if identifier of theObject is "criarDB item identifier" then
		call method "makeKeyAndOrderFront:" of object window "criarDB"
	else if identifier of theObject is "prefs item identifier" then
		
	end if
end clicked toolbar item

on update toolbar item theObject
	-- We return true in order to enable the toolbar item, otherwise we would return false
	return true
end update toolbar item

on will open theObject
	set tabelaBotoes to data source of table view "botoes" of scroll view "botoes" of theObject
	tell tabelaBotoes
		make new data column at the end of the data columns with properties {name:"imagem"}
		make new data column at the end of the data columns with properties {name:"nome"}
		make new data column at the end of the data columns with properties {name:"quantidade"}
	end tell
	
	
	set theRow to make new data row at the end of the data rows of tabelaBotoes
	
	
	set contents of data cell "imagem" of theRow to "printer.png"
	set contents of data cell "nome" of theRow to "1ª Prova"
	
	--set image of image cell "imagem" of theRow to "printer.png"
	
end will open



